import { defineStore } from 'pinia'
import { ref } from 'vue'
import type { LoginResponseData } from '@/type/login'
export const useUserStore = defineStore(
  'user',
  () => {
    const userInfo = ref<LoginResponseData | null>(null)
    const setUserInfo = (newUserInfo: LoginResponseData) => {
      userInfo.value = newUserInfo
    }
    const removeUserInfo = () => {
      userInfo.value = null
    }
    return {
      userInfo,
      setUserInfo,
      removeUserInfo,
    }
  },
  {
    persist: {
      storage: localStorage,
    },
  },
)
